package cn.getech.data.development.utils.hadoop;

import jodd.util.StringUtil;

public class ShellSparkUtils {
    /**
    * 21/07/26 16:37:44 INFO yarn.Client: Submitting application application_1626862194716_11030 to ResourceManager
     * 21/07/26 16:37:45 INFO impl.YarnClientImpl: Submitted application application_1626862194716_11030
     * 21/07/26 16:37:46 INFO yarn.Client: Application report for application_1626862194716_11030 (state: ACCEPTED)
    */
    private static final String sts = "impl.YarnClientImpl: Submitted application application_";
    public static String shellSparkApplictionId(String strLog) {
        if(StringUtil.isNotEmpty(strLog)){
            if(strLog.contains(sts)){
                String[] split = strLog.split(sts);
                if(split != null && split.length >=2){
                    String tmpLogs = split[1];
                    if(StringUtil.isNotEmpty(tmpLogs)){
                        String[] split1 = tmpLogs.split("<br/>");
                        if(split1 != null){
                            return "application_" + split1[0];
                        }
                    }
                }
            }
        }
        return strLog;
    }
}
